from flask import Blueprint, jsonify, request
from services.chinese_words_service import ChineseWordsService
from utils.ocr import recognize_text
from utils.response import success_response, error_response
import base64
import urllib.parse
from services.book_service import BookService
# 创建蓝图
books_bp = Blueprint('books', __name__)
books_service = BookService()
# 获取单个词语
@books_bp.route('/lists', methods=['GET'])
def get_book_list():
    try:
  
        books = books_service.get_books()
        
        if books:
            return success_response(
                message='获取书籍列表成功',
                data=books
            )
        else:
            return error_response(
                message='书籍列表不存在',
                status_code=404
            )
    except Exception as e:
        return error_response(
            message='获取书籍列表失败',
            error=str(e),
            status_code=500
        )
